<!DOCTYPE html>
<html>

<head>
    <script src="angular.js/angular.min.js"></script>
    <script src="js/viewmodel/server_watcher.js"></script>
</head>

<body class="fixed">
    <div class="row">
        <!-- 设备列表清单 BEGIN -->
        <div class="col-lg-3">
            <div class="card mb-4 mb-lg-0">
                <div class="card-header">
                    <div class="d-flex justify-content-between align-items-center">
                        <div>
                            <h6 class="fs-17 font-weight-600 mb-0">转发网关列表</h6>
                        </div>
                        <div class="text-right">
                            <button id="addButton" class="btn btn-primary btn-lg" ng-click="addOne()">添加</button>
                        </div>
                    </div>
                </div>
                <div class="card-body">
                    <div class="dd" id="nestable">
                        <!-- <ol class="dd-list" >
                            <li class="dd-item" ng-repeat="x in gateways" data-id="1" ng-click="toggle(x)">
                                <div class="dd-handle">
                                    <span ng-class="x.name!=currentGateway.name ? 'label bg-green' : 'label bg-red'">
                                        <i class="fas fa-laptop"></i>
                                    </span> {{x.name}}
                                </div>
                            </li>
                        </ol> -->
                        <div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
                            <a style="cursor:pointer" ng-repeat="x in gateways" ng-class="x.ClientName!=currentGateway.ClientName ? 'nav-link' : 'nav-link active'" id="v-pills-home-tab" data-toggle="pill" ng-click="toggle(x)" role="tab" aria-controls="v-pills-home" aria-selected="true">
                                 {{x.ClientName}}                                 
                                <button type="button" style="float:right" class="btn btn-primary btn-circle btn-sm" data-toggle="modal" data-target="#myModal"><i class="fas fa-times"></i></button>

                            </a>
                        </div>
                        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                            <div class="modal-dialog">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <h4 class="modal-title" id="myModalLabel">确认删除？</h4>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                        <button type="button" class="btn btn-primary" data-dismiss="modal" ng-click="removeOne()">确认</button>
                                    </div>
                                </div><!-- /.modal-content -->
                            </div><!-- /.modal-dialog -->
                        </div>
                    </div>
                </div>  
                <!-- <div>
                    <input id="fileUpload" class="btn" type="file" />              
                    <button id="importOldConfigButton" class="btn btn-primary btn-lg" ng-click="importClick()">导入旧的配置</button>
                </div> -->
            </div>
        </div>        
        <!-- 设备列表清单 END -->
        
        <!-- 当前设备配置 BEGIN -->
        <div class="col-lg-9">
            <div class="card mb-4 mb-lg-0">
                <div class="card-header">
                    <div class="d-flex justify-content-between align-items-center">
                        <div>
                            <h6 class="fs-17 font-weight-600 mb-0">服务器转发配置</h6>
                            <h8 class="fs-12 font-weight-400 mb-0">{{currentGateway.ClientName}}</h8>
                        </div>
                        <!-- <div class="text-right">
                            <button id="scanButton" class="btn btn-primary btn-lg" data-toggle="modal"
                                data-target="#subscribeModal" ng-click="test()">扫描设备</button>
                        </div> -->
                    </div>
                </div>
                <div class="card-body">
                    <form>
                        <div class="form-group">
                            <label for="gatewayNameInput" class="font-weight-600">网关名称</label>
                            <div class="input-group mb-3">
                                <input type="text" class="form-control" id="gatewayNameInput"
                                    aria-describedby="gatewayNameHelp" placeholder="名称" ng-model="currentGateway.ClientName">
                            </div>
                            <small id="gatewayNameHelp" class="form-text text-muted">请输入网关唯一名称。PUB:{{currentGateway.PubTopic}} SUB:{{currentGateway.SubTopic}}</small>
                        </div>
                        <div class="form-group">
                            <label for="gatewayPortInput" class="font-weight-600">转发端口</label>
                            <input type="number" class="form-control" id="gatewayPortInput"
                                aria-describedby="gatewayPortHelp" placeholder="转发端口" ng-model="tcpCfg.HostPort"/>
                            <small id="gatewayPortHelp" class="form-text text-muted">请输入虚拟转发的端口号</small>
                        </div>
                        <div class="form-group">
                            <label for="messageRetained" class="font-weight-600">保留离线消息</label>
                            <!-- <input type="checkbox" name="retainedInput" id="messageRetainedInput" ng-model="currentGateway.IsRetained" > -->
                            <select name="retainedInput" class="form-control form-control-lg mt-2" id="messageRetainedInput" aria-describedby="gatewayPortHelp" 
                                 ng-model="currentGateway.Retained" ng-options="x.ID as x.Name for x in retainedTypes">
                                <option value="0">不保留</option>
                                <option value="1">保留</option>
                            </select> 
                            <small id="messageRetained" class="form-text text-muted">请选择是否保留离线消息</small>
                        </div>
                        <div class="form-group">
                            <label for="gatewayPTypeSelect" class="font-weight-600">转发模式</label>
                            <select name="somename" class="form-control form-control-lg mt-2" id="gatewayPTypeSelect" aria-describedby="gatewayPortHelp" 
                                ng-init="tcpCfg.Protocol = ptypes[0]" ng-model="tcpCfg.Protocol" ng-options="x.ID as x.Name for x in ptypes">
                            </select>
                            <small id="gatewayPTypeHelp" class="form-text text-muted">请选择转发模式/规约</small>
                        </div>
                        
                        <div class="form-group" ng-show="tcpCfg.Protocol == 7">
                            <button type="button" class="btn btn-primary btn-circle btn-sm" data-toggle="modal" data-target="#myModal2">配置</button>
                        </div>
                        <div class="modal fade" id="myModal2" tabindex="-2" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                            <div class="modal-dialog">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <h4 class="modal-title" id="myModalLabel2">配置Modbus规约</h4>
                                    </div>
                                    <div class="modal-body">
                                        hello
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                        <button type="button" class="btn btn-primary" data-dismiss="modal" ng-click="removeOne()">确认</button>
                                    </div>
                                </div><!-- /.modal-content -->
                            </div><!-- /.modal-dialog -->
                        </div>
                        <button type="submit" class="btn btn-success" ng-click="saveConfig()">保存修改的配置</button>
                    </form>
                </div>
            </div>
        </div>        
        <!-- 当前设备配置 END -->
    </div>
</body>

</html>